/*
 * Copyright 2015-2018 Igor Maznitsa.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.igormaznitsa.nbmindmap.nb.options;

import com.igormaznitsa.mindmap.model.logger.Logger;
import com.igormaznitsa.mindmap.model.logger.LoggerFactory;
import com.igormaznitsa.mindmap.swing.panel.MindMapPanelConfig;
import com.igormaznitsa.mindmap.swing.panel.utils.KeyShortcut;
import com.igormaznitsa.mindmap.swing.panel.utils.PropertiesPreferences;
import com.igormaznitsa.mindmap.swing.panel.utils.RenderQuality;
import com.igormaznitsa.nbmindmap.nb.editor.MMDGraphEditor;
import com.igormaznitsa.nbmindmap.nb.explorer.MMKnowledgeSources;
import com.igormaznitsa.nbmindmap.nb.refactoring.MindMapRefactoringFactory;
import com.igormaznitsa.nbmindmap.nb.swing.AboutPanel;
import com.igormaznitsa.nbmindmap.nb.swing.KeyShortCutEditPanel;
import com.igormaznitsa.nbmindmap.utils.DialogProviderManager;
import com.igormaznitsa.nbmindmap.utils.NbUtils;
import org.apache.commons.io.FileUtils;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;

import javax.annotation.Nonnull;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.beans.PropertyEditor;
import java.beans.PropertyEditorManager;
import java.io.File;
import java.util.*;
import java.util.List;
import java.util.prefs.Preferences;

final class MMDCfgPanel extends javax.swing.JPanel {

  private static final long serialVersionUID = -1090601330630026253L;

  private static final Logger LOGGER = LoggerFactory.getLogger(MMDCfgPanel.class);

  private final transient MMDCfgOptionsPanelController controller;
  private volatile boolean changeNotificationAllowed = true;

  private final MindMapPanelConfig config = new MindMapPanelConfig();

  private static File lastImportedSettingsFile = null;
  private static File lastExportedSettingsFile = null;

  private final Map<String, KeyShortcut> mapKeyShortCuts = new TreeMap<String, KeyShortcut>(new Comparator<String>() {
    @Override
    public int compare(final String o1, final String o2) {
      return o1.compareTo(o2);
    }
  });

  private static final class PropertiesFileFilter extends FileFilter {

    @Override
    public boolean accept(@Nonnull final File f) {
      return f.isDirectory() || f.getName().toLowerCase(Locale.ENGLISH).endsWith(".properties");
    }

    @Override
    @Nonnull
    public String getDescription() {
      return "Java properties file (*.properties)";
    }

  }

  MMDCfgPanel(final MMDCfgOptionsPanelController controller) {
    this.controller = controller;
    initComponents();
    this.labelMiscNeedsReloading.setVisible(false);
  }

  /**
   * This method is called from within the constructor to initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is always
   * regenerated by the Form Editor.
   */
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    jScrollPane1 = new javax.swing.JScrollPane();
    jPanel6 = new javax.swing.JPanel();
    jPanel3 = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    spinnerConnectorWidth = new javax.swing.JSpinner();
    jLabel5 = new javax.swing.JLabel();
    spinnerCollapsatorSize = new javax.swing.JSpinner();
    jLabel6 = new javax.swing.JLabel();
    spinnerCollapsatorWidth = new javax.swing.JSpinner();
    jLabel7 = new javax.swing.JLabel();
    spinnerJumpLinkWidth = new javax.swing.JSpinner();
    jPanel10 = new javax.swing.JPanel();
    colorChooserCollapsatorBackground = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    colorChooserJumpLink = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    colorChooserCollapsatorBorder = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    colorChooserConnectorColor = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    jPanel4 = new javax.swing.JPanel();
    colorChooserPaperColor = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    checkBoxShowGrid = new javax.swing.JCheckBox();
    colorChooserGridColor = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    spinnerGridStep = new javax.swing.JSpinner();
    jLabel1 = new javax.swing.JLabel();
    jPanel13 = new javax.swing.JPanel();
    comboBoxRenderQuality = new javax.swing.JComboBox();
    jPanel2 = new javax.swing.JPanel();
    checkBoxDropShadow = new javax.swing.JCheckBox();
    jPanel7 = new javax.swing.JPanel();
    buttonFont = new javax.swing.JButton();
    jPanel8 = new javax.swing.JPanel();
    buttonOpenShortcutEditor = new javax.swing.JButton();
    panelScalingModifiers = new javax.swing.JPanel();
    checkBoxScalingCTRL = new javax.swing.JCheckBox();
    checkBoxScalingALT = new javax.swing.JCheckBox();
    checkBoxScalingSHIFT = new javax.swing.JCheckBox();
    checkBoxScalingMETA = new javax.swing.JCheckBox();
    jPanel11 = new javax.swing.JPanel();
    colorChooserRootText = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    colorChooserRootBackground = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    colorChooser1stBackground = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    colorChooser2ndBackground = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    colorChooser1stText = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    colorChooser2ndText = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    jPanel12 = new javax.swing.JPanel();
    labelBorderWidth = new javax.swing.JLabel();
    spinnerElementBorderWidth = new javax.swing.JSpinner();
    jPanel14 = new javax.swing.JPanel();
    slider1stLevelHorzGap = new javax.swing.JSlider();
    jPanel15 = new javax.swing.JPanel();
    slider1stLevelVertGap = new javax.swing.JSlider();
    jPanel16 = new javax.swing.JPanel();
    slider2ndLevelHorzGap = new javax.swing.JSlider();
    jPanel17 = new javax.swing.JPanel();
    slider2ndLevelVertGap = new javax.swing.JSlider();
    jPanel1 = new javax.swing.JPanel();
    checkboxUseInsideBrowser = new javax.swing.JCheckBox();
    checkboxRelativePathsForFilesInTheProject = new javax.swing.JCheckBox();
    checkBoxUnfoldCollapsedTarget = new javax.swing.JCheckBox();
    checkBoxCopyColorInfoToNewAllowed = new javax.swing.JCheckBox();
    checkBoxKnowledgeFolderAutogenerationAllowed = new javax.swing.JCheckBox();
    checkBoxWatchFileRefactoring = new javax.swing.JCheckBox();
    checkBoxIgnoreWhereUsedRequests = new javax.swing.JCheckBox();
    labelMiscNeedsReloading = new javax.swing.JLabel();
    checkboxTrimTopicText = new javax.swing.JCheckBox();
    checkBoxSmartTextPaste = new javax.swing.JCheckBox();
    jPanel5 = new javax.swing.JPanel();
    colorChooserSelectLine = new com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton();
    jLabel3 = new javax.swing.JLabel();
    spinnerSelectLineWidth = new javax.swing.JSpinner();
    jLabel4 = new javax.swing.JLabel();
    spinnerSelectLineGap = new javax.swing.JSpinner();
    jPanel9 = new javax.swing.JPanel();
    buttonAbout = new javax.swing.JButton();
    donateButton1 = new com.igormaznitsa.nbmindmap.nb.swing.DonateButton();
    buttonResetSettings = new javax.swing.JButton();
    buttonExportSettings = new javax.swing.JButton();
    buttonImportSettings = new javax.swing.JButton();
    filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 16), new java.awt.Dimension(0, 16), new java.awt.Dimension(32767, 16));
    filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
    filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
    filler6 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
    filler7 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 16), new java.awt.Dimension(0, 16), new java.awt.Dimension(32767, 16));
    filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0));
    filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));

    setLayout(new java.awt.BorderLayout());

    jPanel6.setLayout(new java.awt.GridBagLayout());

    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle"); // NOI18N
    jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.jPanel3.border.title"))); // NOI18N
    jPanel3.setLayout(new java.awt.GridBagLayout());

    jLabel2.setText(bundle.getString("MMDCfgPanel.jLabel2.text")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
    jPanel3.add(jLabel2, gridBagConstraints);

    spinnerConnectorWidth.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.1f), Float.valueOf(0.05f), Float.valueOf(20.0f), Float.valueOf(0.01f)));
    spinnerConnectorWidth.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        spinnerConnectorWidthStateChanged(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.ipadx = 82;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1000.0;
    jPanel3.add(spinnerConnectorWidth, gridBagConstraints);

    jLabel5.setText(bundle.getString("MMDCfgPanel.jLabel5.text")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
    jPanel3.add(jLabel5, gridBagConstraints);

    spinnerCollapsatorSize.setModel(new javax.swing.SpinnerNumberModel(5, 3, 500, 1));
    spinnerCollapsatorSize.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        spinnerCollapsatorSizeStateChanged(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.ipadx = 93;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1000.0;
    jPanel3.add(spinnerCollapsatorSize, gridBagConstraints);

    jLabel6.setText(bundle.getString("MMDCfgPanel.jLabel6.text")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
    jPanel3.add(jLabel6, gridBagConstraints);

    spinnerCollapsatorWidth.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(0.01f), Float.valueOf(100.0f), Float.valueOf(0.1f)));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.ipadx = 82;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1000.0;
    jPanel3.add(spinnerCollapsatorWidth, gridBagConstraints);

    jLabel7.setText(bundle.getString("MMDCfgPanel.jLabel7.text")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
    jPanel3.add(jLabel7, gridBagConstraints);

    spinnerJumpLinkWidth.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.1f), Float.valueOf(0.05f), Float.valueOf(20.0f), Float.valueOf(0.01f)));
    spinnerJumpLinkWidth.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        spinnerJumpLinkWidthStateChanged(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.ipadx = 82;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1000.0;
    jPanel3.add(spinnerJumpLinkWidth, gridBagConstraints);

    jPanel10.setBorder(null);
    jPanel10.setLayout(new java.awt.GridLayout(2, 2));

    colorChooserCollapsatorBackground.setText(bundle.getString("MMDCfgPanel.colorChooserCollapsatorBackground.text")); // NOI18N
    colorChooserCollapsatorBackground.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserCollapsatorBackground.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserCollapsatorBackgroundActionPerformed(evt);
      }
    });
    jPanel10.add(colorChooserCollapsatorBackground);

    colorChooserJumpLink.setText(bundle.getString("MMDCfgPanel.colorChooserJumpLink.text")); // NOI18N
    colorChooserJumpLink.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserJumpLink.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserJumpLinkActionPerformed(evt);
      }
    });
    jPanel10.add(colorChooserJumpLink);

    colorChooserCollapsatorBorder.setText(bundle.getString("MMDCfgPanel.colorChooserCollapsatorBorder.text")); // NOI18N
    colorChooserCollapsatorBorder.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserCollapsatorBorder.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserCollapsatorBorderActionPerformed(evt);
      }
    });
    jPanel10.add(colorChooserCollapsatorBorder);

    colorChooserConnectorColor.setText(bundle.getString("MMDCfgPanel.colorChooserConnectorColor.text")); // NOI18N
    colorChooserConnectorColor.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserConnectorColor.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserConnectorColorActionPerformed(evt);
      }
    });
    jPanel10.add(colorChooserConnectorColor);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    jPanel3.add(jPanel10, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel6.add(jPanel3, gridBagConstraints);

    jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.jPanel4.border.title"))); // NOI18N
    jPanel4.setLayout(new java.awt.GridBagLayout());

    colorChooserPaperColor.setText(bundle.getString("MMDCfgPanel.colorChooserPaperColor.text")); // NOI18N
    colorChooserPaperColor.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserPaperColor.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserPaperColorActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel4.add(colorChooserPaperColor, gridBagConstraints);

    checkBoxShowGrid.setText(bundle.getString("MMDCfgPanel.checkBoxShowGrid.text")); // NOI18N
    checkBoxShowGrid.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxShowGridActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.ipady = 10;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel4.add(checkBoxShowGrid, gridBagConstraints);

    colorChooserGridColor.setText(bundle.getString("MMDCfgPanel.colorChooserGridColor.text")); // NOI18N
    colorChooserGridColor.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserGridColor.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserGridColorActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel4.add(colorChooserGridColor, gridBagConstraints);

    spinnerGridStep.setModel(new javax.swing.SpinnerNumberModel(15, 2, 500, 1));
    spinnerGridStep.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        spinnerGridStepStateChanged(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipadx = 31;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel4.add(spinnerGridStep, gridBagConstraints);

    jLabel1.setText(bundle.getString("MMDCfgPanel.jLabel1.text")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.ipady = 11;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel4.add(jLabel1, gridBagConstraints);

    jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.RenderQuality.border.title"))); // NOI18N
    jPanel13.setLayout(new java.awt.GridLayout(1, 0));

    comboBoxRenderQuality.setModel(new DefaultComboBoxModel<RenderQuality>(RenderQuality.values()));
    comboBoxRenderQuality.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        comboBoxRenderQualityActionPerformed(evt);
      }
    });
    jPanel13.add(comboBoxRenderQuality);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel4.add(jPanel13, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel6.add(jPanel4, gridBagConstraints);

    jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.jPanel2.border.title"))); // NOI18N
    jPanel2.setLayout(new java.awt.GridBagLayout());

    checkBoxDropShadow.setText(bundle.getString("MMDCfgPanel.checkBoxDropShadow.text")); // NOI18N
    checkBoxDropShadow.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxDropShadowActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel2.add(checkBoxDropShadow, gridBagConstraints);

    jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.jPanel7.border.title"))); // NOI18N

    buttonFont.setText("..."); // NOI18N
    buttonFont.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        buttonFontActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
    jPanel7.setLayout(jPanel7Layout);
    jPanel7Layout.setHorizontalGroup(
      jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel7Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(buttonFont, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
        .addContainerGap())
    );
    jPanel7Layout.setVerticalGroup(
      jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel7Layout.createSequentialGroup()
        .addComponent(buttonFont)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel2.add(jPanel7, gridBagConstraints);

    jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.ShortCutsTitle"))); // NOI18N

    buttonOpenShortcutEditor.setText(bundle.getString("MMDCfgPanel.ShortCutsButtonText")); // NOI18N
    buttonOpenShortcutEditor.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        buttonOpenShortcutEditorActionPerformed(evt);
      }
    });

    panelScalingModifiers.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.panelScalingModifiers.border.title"))); // NOI18N

    checkBoxScalingCTRL.setText("CTRL"); // NOI18N
    checkBoxScalingCTRL.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxScalingCTRLActionPerformed(evt);
      }
    });

    checkBoxScalingALT.setText("ALT"); // NOI18N
    checkBoxScalingALT.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxScalingALTActionPerformed(evt);
      }
    });

    checkBoxScalingSHIFT.setText("SHIFT"); // NOI18N
    checkBoxScalingSHIFT.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxScalingSHIFTActionPerformed(evt);
      }
    });

    checkBoxScalingMETA.setText("META"); // NOI18N
    checkBoxScalingMETA.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxScalingMETAActionPerformed(evt);
      }
    });

    javax.swing.GroupLayout panelScalingModifiersLayout = new javax.swing.GroupLayout(panelScalingModifiers);
    panelScalingModifiers.setLayout(panelScalingModifiersLayout);
    panelScalingModifiersLayout.setHorizontalGroup(
      panelScalingModifiersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(panelScalingModifiersLayout.createSequentialGroup()
        .addContainerGap()
        .addComponent(checkBoxScalingCTRL)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(checkBoxScalingALT)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(checkBoxScalingSHIFT)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(checkBoxScalingMETA)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    panelScalingModifiersLayout.setVerticalGroup(
      panelScalingModifiersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(panelScalingModifiersLayout.createSequentialGroup()
        .addContainerGap()
        .addGroup(panelScalingModifiersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(checkBoxScalingCTRL)
          .addComponent(checkBoxScalingALT)
          .addComponent(checkBoxScalingSHIFT)
          .addComponent(checkBoxScalingMETA))
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
    jPanel8.setLayout(jPanel8Layout);
    jPanel8Layout.setHorizontalGroup(
      jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel8Layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
          .addComponent(buttonOpenShortcutEditor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
          .addComponent(panelScalingModifiers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        .addContainerGap())
    );
    jPanel8Layout.setVerticalGroup(
      jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(jPanel8Layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(buttonOpenShortcutEditor)
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
        .addComponent(panelScalingModifiers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel2.add(jPanel8, gridBagConstraints);

    jPanel11.setLayout(new java.awt.GridLayout(3, 2));

    colorChooserRootText.setText(bundle.getString("MMDCfgPanel.colorChooserRootText.text")); // NOI18N
    colorChooserRootText.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserRootText.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserRootTextActionPerformed(evt);
      }
    });
    jPanel11.add(colorChooserRootText);

    colorChooserRootBackground.setText(bundle.getString("MMDCfgPanel.colorChooserRootBackground.text")); // NOI18N
    colorChooserRootBackground.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserRootBackground.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserRootBackgroundActionPerformed(evt);
      }
    });
    jPanel11.add(colorChooserRootBackground);

    colorChooser1stBackground.setText(bundle.getString("MMDCfgPanel.colorChooser1stBackground.text")); // NOI18N
    colorChooser1stBackground.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooser1stBackground.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooser1stBackgroundActionPerformed(evt);
      }
    });
    jPanel11.add(colorChooser1stBackground);

    colorChooser2ndBackground.setText(bundle.getString("MMDCfgPanel.colorChooser2ndBackground.text")); // NOI18N
    colorChooser2ndBackground.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooser2ndBackground.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooser2ndBackgroundActionPerformed(evt);
      }
    });
    jPanel11.add(colorChooser2ndBackground);

    colorChooser1stText.setText(bundle.getString("MMDCfgPanel.colorChooser1stText.text")); // NOI18N
    colorChooser1stText.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooser1stText.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooser1stTextActionPerformed(evt);
      }
    });
    jPanel11.add(colorChooser1stText);

    colorChooser2ndText.setText(bundle.getString("MMDCfgPanel.colorChooser2ndText.text")); // NOI18N
    colorChooser2ndText.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooser2ndText.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooser2ndTextActionPerformed(evt);
      }
    });
    jPanel11.add(colorChooser2ndText);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    jPanel2.add(jPanel11, gridBagConstraints);

    labelBorderWidth.setText(bundle.getString("MMDCfgPanel.labelBorderWidth.text")); // NOI18N
    jPanel12.add(labelBorderWidth);

    spinnerElementBorderWidth.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.5f), Float.valueOf(0.05f), Float.valueOf(50.0f), Float.valueOf(0.1f)));
    spinnerElementBorderWidth.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        spinnerElementBorderWidthStateChanged(evt);
      }
    });
    jPanel12.add(spinnerElementBorderWidth);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel2.add(jPanel12, gridBagConstraints);

    jPanel14.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.panel1stLevelHorzGap.border.title"))); // NOI18N
    jPanel14.setLayout(new java.awt.BorderLayout());

    slider1stLevelHorzGap.setMajorTickSpacing(30);
    slider1stLevelHorzGap.setMaximum(250);
    slider1stLevelHorzGap.setMinimum(10);
    slider1stLevelHorzGap.setPaintLabels(true);
    slider1stLevelHorzGap.setPaintTicks(true);
    slider1stLevelHorzGap.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        slider1stLevelHorzGapStateChanged(evt);
      }
    });
    jPanel14.add(slider1stLevelHorzGap, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel2.add(jPanel14, gridBagConstraints);

    jPanel15.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.panel1stLevelVertGap.border.title"))); // NOI18N
    jPanel15.setLayout(new java.awt.BorderLayout());

    slider1stLevelVertGap.setMajorTickSpacing(30);
    slider1stLevelVertGap.setMaximum(250);
    slider1stLevelVertGap.setMinimum(10);
    slider1stLevelVertGap.setPaintLabels(true);
    slider1stLevelVertGap.setPaintTicks(true);
    slider1stLevelVertGap.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        slider1stLevelVertGapStateChanged(evt);
      }
    });
    jPanel15.add(slider1stLevelVertGap, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel2.add(jPanel15, gridBagConstraints);

    jPanel16.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.panel2ndLevelHorzGap.border.title"))); // NOI18N
    jPanel16.setLayout(new java.awt.BorderLayout());

    slider2ndLevelHorzGap.setMajorTickSpacing(30);
    slider2ndLevelHorzGap.setMaximum(250);
    slider2ndLevelHorzGap.setMinimum(10);
    slider2ndLevelHorzGap.setPaintLabels(true);
    slider2ndLevelHorzGap.setPaintTicks(true);
    slider2ndLevelHorzGap.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        slider2ndLevelHorzGapStateChanged(evt);
      }
    });
    jPanel16.add(slider2ndLevelHorzGap, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel2.add(jPanel16, gridBagConstraints);

    jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.panel2ndLevelVertGap.border.title"))); // NOI18N
    jPanel17.setLayout(new java.awt.BorderLayout());

    slider2ndLevelVertGap.setMajorTickSpacing(30);
    slider2ndLevelVertGap.setMaximum(250);
    slider2ndLevelVertGap.setMinimum(10);
    slider2ndLevelVertGap.setPaintLabels(true);
    slider2ndLevelVertGap.setPaintTicks(true);
    slider2ndLevelVertGap.addChangeListener(new javax.swing.event.ChangeListener() {
      public void stateChanged(javax.swing.event.ChangeEvent evt) {
        slider2ndLevelVertGapStateChanged(evt);
      }
    });
    jPanel17.add(slider2ndLevelVertGap, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel2.add(jPanel17, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 4;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel6.add(jPanel2, gridBagConstraints);

    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.jPanel1.border.title"))); // NOI18N
    jPanel1.setLayout(new java.awt.GridBagLayout());

    checkboxUseInsideBrowser.setText(bundle.getString("MMDCfgPanel.checkboxUseInsideBrowser.text")); // NOI18N
    checkboxUseInsideBrowser.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkboxUseInsideBrowserActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(checkboxUseInsideBrowser, gridBagConstraints);

    checkboxRelativePathsForFilesInTheProject.setText(bundle.getString("MMDCfgPanel.checkboxRelativePathsForFilesInTheProject.text")); // NOI18N
    checkboxRelativePathsForFilesInTheProject.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkboxRelativePathsForFilesInTheProjectActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(checkboxRelativePathsForFilesInTheProject, gridBagConstraints);

    checkBoxUnfoldCollapsedTarget.setText(bundle.getString("MMDCfgPanel.checkBoxUnfoldCollapsedTarget.text")); // NOI18N
    checkBoxUnfoldCollapsedTarget.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxUnfoldCollapsedTargetActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(checkBoxUnfoldCollapsedTarget, gridBagConstraints);

    checkBoxCopyColorInfoToNewAllowed.setText(bundle.getString("MMDCfgPanel.checkBoxCopyColorInfoToNewAllowed.text")); // NOI18N
    checkBoxCopyColorInfoToNewAllowed.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxCopyColorInfoToNewAllowedActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(checkBoxCopyColorInfoToNewAllowed, gridBagConstraints);

    checkBoxKnowledgeFolderAutogenerationAllowed.setText(bundle.getString("MMDCfgPanel.checkBoxKnowledgeFolderAutogenerationAllowed.text")); // NOI18N
    checkBoxKnowledgeFolderAutogenerationAllowed.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxKnowledgeFolderAutogenerationAllowedActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(checkBoxKnowledgeFolderAutogenerationAllowed, gridBagConstraints);

    checkBoxWatchFileRefactoring.setText("Watch file refactoring (Experimental)"); // NOI18N
    checkBoxWatchFileRefactoring.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxWatchFileRefactoringActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(checkBoxWatchFileRefactoring, gridBagConstraints);

    checkBoxIgnoreWhereUsedRequests.setText("Turn off processing of \"Where used\" refactoring"); // NOI18N
    checkBoxIgnoreWhereUsedRequests.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxIgnoreWhereUsedRequestsActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(checkBoxIgnoreWhereUsedRequests, gridBagConstraints);

    labelMiscNeedsReloading.setForeground(java.awt.Color.red);
    labelMiscNeedsReloading.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    labelMiscNeedsReloading.setText("IDE should be reloaded for effect"); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 9;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(labelMiscNeedsReloading, gridBagConstraints);

    checkboxTrimTopicText.setText(bundle.getString("MMDCfgPanel.checkboxTrimTopicText.text")); // NOI18N
    checkboxTrimTopicText.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkboxTrimTopicTextActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel1.add(checkboxTrimTopicText, gridBagConstraints);

    checkBoxSmartTextPaste.setText(bundle.getString("MMDCfgPanel.checkBoxSmartTextPaste.text")); // NOI18N
    checkBoxSmartTextPaste.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        checkBoxSmartTextPasteActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 8;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    jPanel1.add(checkBoxSmartTextPaste, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel6.add(jPanel1, gridBagConstraints);

    jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("MMDCfgPanel.jPanel5.border.title"))); // NOI18N
    jPanel5.setLayout(new java.awt.GridBagLayout());

    colorChooserSelectLine.setText(bundle.getString("MMDCfgPanel.colorChooserSelectLine.text")); // NOI18N
    colorChooserSelectLine.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
    colorChooserSelectLine.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        colorChooserSelectLineActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1000.0;
    jPanel5.add(colorChooserSelectLine, gridBagConstraints);

    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    jLabel3.setText(bundle.getString("MMDCfgPanel.jLabel3.text")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipady = 11;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1000.0;
    jPanel5.add(jLabel3, gridBagConstraints);

    spinnerSelectLineWidth.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(1.0f), Float.valueOf(0.02f), Float.valueOf(100.0f), Float.valueOf(0.1f)));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 86;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1000.0;
    jPanel5.add(spinnerSelectLineWidth, gridBagConstraints);

    jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    jLabel4.setText(bundle.getString("MMDCfgPanel.jLabel4.text")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipady = 11;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel5.add(jLabel4, gridBagConstraints);

    spinnerSelectLineGap.setModel(new javax.swing.SpinnerNumberModel(1, 1, 500, 1));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.ipadx = 97;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1000.0;
    jPanel5.add(spinnerSelectLineGap, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    jPanel6.add(jPanel5, gridBagConstraints);

    jPanel9.setBorder(null);
    jPanel9.setLayout(new java.awt.GridBagLayout());

    buttonAbout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/nbmindmap/icons/info16.png"))); // NOI18N
    buttonAbout.setText(bundle.getString("MMDCfgPanel.buttonAbout.Text")); // NOI18N
    buttonAbout.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        buttonAboutActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel9.add(buttonAbout, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel9.add(donateButton1, gridBagConstraints);

    buttonResetSettings.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/nbmindmap/icons/stop16.png"))); // NOI18N
    buttonResetSettings.setText(bundle.getString("MMDCfgPanel.buttonResetSettings.text"));
    buttonResetSettings.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        buttonResetSettingsActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel9.add(buttonResetSettings, gridBagConstraints);

    buttonExportSettings.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/nbmindmap/icons/document_export16.png"))); // NOI18N
    buttonExportSettings.setText(bundle.getString("MMDCfgPanel.buttonExportSettings.text"));
    buttonExportSettings.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        buttonExportSettingsActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel9.add(buttonExportSettings, gridBagConstraints);

    buttonImportSettings.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/nbmindmap/icons/document_import16.png"))); // NOI18N
    buttonImportSettings.setText(bundle.getString("MMDCfgPanel.buttonImportSettings.text"));
    buttonImportSettings.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
        buttonImportSettingsActionPerformed(evt);
      }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel9.add(buttonImportSettings, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 3;
    jPanel9.add(filler4, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 7;
    gridBagConstraints.weighty = 1000.0;
    jPanel9.add(filler5, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    jPanel9.add(filler2, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    jPanel9.add(filler6, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    jPanel9.add(filler7, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    jPanel6.add(jPanel9, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.weightx = 1000.0;
    jPanel6.add(filler1, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.weighty = 1000.0;
    jPanel6.add(filler3, gridBagConstraints);

    jScrollPane1.setViewportView(jPanel6);

    add(jScrollPane1, java.awt.BorderLayout.CENTER);
  }// </editor-fold>//GEN-END:initComponents

  private void checkBoxShowGridActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxShowGridActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxShowGridActionPerformed

  private void checkBoxDropShadowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxDropShadowActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxDropShadowActionPerformed

  private void colorChooserPaperColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserPaperColorActionPerformed
    if (this.colorChooserPaperColor.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserPaperColorActionPerformed

  private void colorChooserGridColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserGridColorActionPerformed
    if (this.colorChooserGridColor.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserGridColorActionPerformed

  private void spinnerConnectorWidthStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerConnectorWidthStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_spinnerConnectorWidthStateChanged

  private void colorChooserConnectorColorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserConnectorColorActionPerformed
    if (this.colorChooserConnectorColor.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserConnectorColorActionPerformed

  private void colorChooserRootBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserRootBackgroundActionPerformed
    if (this.colorChooserRootBackground.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserRootBackgroundActionPerformed

  private void colorChooserRootTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserRootTextActionPerformed
    if (this.colorChooserRootText.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserRootTextActionPerformed

  private void colorChooser1stBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooser1stBackgroundActionPerformed
    if (this.colorChooser1stBackground.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooser1stBackgroundActionPerformed

  private void colorChooser1stTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooser1stTextActionPerformed
    if (this.colorChooser1stText.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooser1stTextActionPerformed

  private void colorChooser2ndBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooser2ndBackgroundActionPerformed
    if (this.colorChooser2ndBackground.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooser2ndBackgroundActionPerformed

  private void colorChooser2ndTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooser2ndTextActionPerformed
    if (this.colorChooser2ndText.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooser2ndTextActionPerformed

  private void colorChooserSelectLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserSelectLineActionPerformed
    if (this.colorChooserSelectLine.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserSelectLineActionPerformed

  private void colorChooserCollapsatorBorderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserCollapsatorBorderActionPerformed
    if (changeNotificationAllowed && this.colorChooserCollapsatorBorder.isLastOkPressed()) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserCollapsatorBorderActionPerformed

  private void colorChooserCollapsatorBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserCollapsatorBackgroundActionPerformed
    if (changeNotificationAllowed && this.colorChooserCollapsatorBackground.isLastOkPressed()) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserCollapsatorBackgroundActionPerformed

  private void spinnerCollapsatorSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerCollapsatorSizeStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_spinnerCollapsatorSizeStateChanged

  private void slider1stLevelHorzGapStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_slider1stLevelHorzGapStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_slider1stLevelHorzGapStateChanged

  private void slider1stLevelVertGapStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_slider1stLevelVertGapStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_slider1stLevelVertGapStateChanged

  private void slider2ndLevelHorzGapStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_slider2ndLevelHorzGapStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_slider2ndLevelHorzGapStateChanged

  private void slider2ndLevelVertGapStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_slider2ndLevelVertGapStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_slider2ndLevelVertGapStateChanged

  private void updateFontButton(@Nonnull final MindMapPanelConfig config) {
    final String strStyle;

    final Font thefont = config.getFont();

    if (thefont.isBold()) {
      strStyle = thefont.isItalic() ? "bolditalic" : "bold";
    } else {
      strStyle = thefont.isItalic() ? "italic" : "plain";
    }

    this.buttonFont.setText(thefont.getName() + ", " + strStyle + ", " + thefont.getSize());
  }

  private void buttonFontActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFontActionPerformed
    final PropertyEditor editor = PropertyEditorManager.findEditor(Font.class);
    if (editor == null) {
      LOGGER.error("Can't find any font editor");
      NbUtils.msgError(null, "Can't find editor! Unexpected state! Contact developer!");
      return;
    }
    editor.setValue(this.config.getFont());

    final DialogDescriptor descriptor = new DialogDescriptor(
        editor.getCustomEditor(),
        "Mind map font"
    );

    DialogDisplayer.getDefault().createDialog(descriptor).setVisible(true);
    if (descriptor.getValue() == DialogDescriptor.OK_OPTION) {
      this.config.setFont((Font) editor.getValue());
      updateFontButton(this.config);
      if (changeNotificationAllowed) {
        this.controller.changed();
      }
    }
  }//GEN-LAST:event_buttonFontActionPerformed

  private void buttonAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAboutActionPerformed
    NbUtils.plainMessageOk(null, java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("MMDCfgPanel.buttonAbout.Text"), new AboutPanel());
  }//GEN-LAST:event_buttonAboutActionPerformed

  private void checkboxUseInsideBrowserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkboxUseInsideBrowserActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkboxUseInsideBrowserActionPerformed

  private void checkboxRelativePathsForFilesInTheProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkboxRelativePathsForFilesInTheProjectActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkboxRelativePathsForFilesInTheProjectActionPerformed

  private void checkBoxUnfoldCollapsedTargetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxUnfoldCollapsedTargetActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxUnfoldCollapsedTargetActionPerformed

  private void colorChooserJumpLinkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserJumpLinkActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_colorChooserJumpLinkActionPerformed

  private void spinnerJumpLinkWidthStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerJumpLinkWidthStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_spinnerJumpLinkWidthStateChanged

  private void checkBoxCopyColorInfoToNewAllowedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxCopyColorInfoToNewAllowedActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxCopyColorInfoToNewAllowedActionPerformed

  private void checkBoxKnowledgeFolderAutogenerationAllowedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxKnowledgeFolderAutogenerationAllowedActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxKnowledgeFolderAutogenerationAllowedActionPerformed

  private void buttonOpenShortcutEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOpenShortcutEditorActionPerformed
    final List<KeyShortcut> list = new ArrayList<KeyShortcut>();
    for (final Map.Entry<String, KeyShortcut> e : this.mapKeyShortCuts.entrySet()) {
      list.add(e.getValue());
    }
    final KeyShortCutEditPanel panel = new KeyShortCutEditPanel(list);
    if (NbUtils.plainMessageOkCancel(null, "Edit shortcuts", panel)) {
      for (final KeyShortcut s : panel.getResult()) {
        this.mapKeyShortCuts.put(s.getID(), s);
      }
      this.controller.changed();
    }
  }//GEN-LAST:event_buttonOpenShortcutEditorActionPerformed

  private void checkBoxScalingCTRLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxScalingCTRLActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxScalingCTRLActionPerformed

  private void checkBoxScalingALTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxScalingALTActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxScalingALTActionPerformed

  private void checkBoxScalingSHIFTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxScalingSHIFTActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxScalingSHIFTActionPerformed

  private void checkBoxScalingMETAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxScalingMETAActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxScalingMETAActionPerformed

  private void buttonResetSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonResetSettingsActionPerformed
    this.config.makeFullCopyOf(new MindMapPanelConfig(), false, false);
    loadFromPreferences(new PropertiesPreferences("NB MindMap plugin"), this.config);
    this.controller.changed();
  }//GEN-LAST:event_buttonResetSettingsActionPerformed

  private void buttonExportSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExportSettingsActionPerformed
    File file = DialogProviderManager.getInstance().getDialogProvider().msgSaveFileDialog(null, "exportSettings", "Export settings", lastExportedSettingsFile, true, new PropertiesFileFilter(), "Save");
    if (file != null) {
      lastExportedSettingsFile = file;
      if (!file.getName().toLowerCase(Locale.ENGLISH).endsWith(".properties")) {
        final Boolean addExt = DialogProviderManager.getInstance().getDialogProvider().msgConfirmYesNoCancel(null, "Add extension", "Add '.properties' extension?");
        if (addExt == null) {
          return;
        }
        if (addExt) {
          file = new File(file.getAbsolutePath() + ".properties");
        }
      }

      if (file.exists() && !DialogProviderManager.getInstance().getDialogProvider().msgConfirmOkCancel(null, "Override file", String.format("File %s exists, to override it?", file.getName()))) {
        return;
      }

      final PropertiesPreferences prefs = new PropertiesPreferences("NB MindMap plugin");
      final MindMapPanelConfig cfg = store(prefs, new MindMapPanelConfig(), false);
      cfg.saveTo(prefs);
      try {
        FileUtils.write(file, prefs.toString(), "UTF-8");
      } catch (final Exception ex) {
        LOGGER.error("Can't export settings", ex);
        DialogProviderManager.getInstance().getDialogProvider().msgError(null, "Can't export settings [" + ex.getMessage() + ']');
      }
    }
  }//GEN-LAST:event_buttonExportSettingsActionPerformed

  private void buttonImportSettingsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonImportSettingsActionPerformed
    final File file = DialogProviderManager.getInstance().getDialogProvider().msgOpenFileDialog(null, "importSettings", "Import settings", lastImportedSettingsFile, true, new PropertiesFileFilter(), "Open");
    if (file != null) {
      lastImportedSettingsFile = file;
      try {
        final Preferences prefs = (new PropertiesPreferences("NB MindMap plugin", FileUtils.readFileToString(file, "UTF-8")));
        loadFromPreferences(prefs, this.config);
        this.controller.changed();
      } catch (final Exception ex) {
        LOGGER.error("Can't import settings", ex);
        DialogProviderManager.getInstance().getDialogProvider().msgError(null, "Can't import settings [" + ex.getMessage() + ']');
      }
    }
  }//GEN-LAST:event_buttonImportSettingsActionPerformed

  private void checkBoxWatchFileRefactoringActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxWatchFileRefactoringActionPerformed
    if (this.changeNotificationAllowed) {
      showNeedsReloadingNotification();
    }
  }//GEN-LAST:event_checkBoxWatchFileRefactoringActionPerformed

  private void checkBoxIgnoreWhereUsedRequestsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxIgnoreWhereUsedRequestsActionPerformed
    if (this.changeNotificationAllowed) {
      showNeedsReloadingNotification();
    }
  }//GEN-LAST:event_checkBoxIgnoreWhereUsedRequestsActionPerformed

  private void checkboxTrimTopicTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkboxTrimTopicTextActionPerformed
    if (this.changeNotificationAllowed) {
      showNeedsReloadingNotification();
    }
  }//GEN-LAST:event_checkboxTrimTopicTextActionPerformed

  private void spinnerElementBorderWidthStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerElementBorderWidthStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_spinnerElementBorderWidthStateChanged

  private void comboBoxRenderQualityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboBoxRenderQualityActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_comboBoxRenderQualityActionPerformed

  private void spinnerGridStepStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerGridStepStateChanged
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_spinnerGridStepStateChanged

  private void checkBoxSmartTextPasteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxSmartTextPasteActionPerformed
    if (changeNotificationAllowed) {
      this.controller.changed();
    }
  }//GEN-LAST:event_checkBoxSmartTextPasteActionPerformed

  private void showNeedsReloadingNotification() {
    this.labelMiscNeedsReloading.setVisible(true);
  }

  void load(@Nonnull final Preferences preferences) {
    loadFromPreferences(preferences, this.config);
  }

  private void loadFromPreferences(@Nonnull final Preferences preferences, @Nonnull final MindMapPanelConfig cfg) {
    cfg.loadFrom(preferences);

    this.changeNotificationAllowed = false;
    try {
      this.checkBoxShowGrid.setSelected(cfg.isShowGrid());
      this.checkBoxDropShadow.setSelected(cfg.isDropShadow());
      this.colorChooserPaperColor.setValue(cfg.getPaperColor());
      this.colorChooserGridColor.setValue(cfg.getGridColor());
      this.colorChooserConnectorColor.setValue(cfg.getConnectorColor());
      this.colorChooserJumpLink.setValue(cfg.getJumpLinkColor());

      this.colorChooserRootBackground.setValue(cfg.getRootBackgroundColor());
      this.colorChooserRootText.setValue(cfg.getRootTextColor());

      this.colorChooser1stBackground.setValue(cfg.getFirstLevelBackgroundColor());
      this.colorChooser1stText.setValue(cfg.getFirstLevelTextColor());

      this.colorChooser2ndBackground.setValue(cfg.getOtherLevelBackgroundColor());
      this.colorChooser2ndText.setValue(cfg.getOtherLevelTextColor());

      this.colorChooserSelectLine.setValue(cfg.getSelectLineColor());

      this.spinnerGridStep.setValue(cfg.getGridStep());
      this.spinnerSelectLineGap.setValue(cfg.getSelectLineGap());
      this.spinnerConnectorWidth.setValue(cfg.getConnectorWidth());
      this.spinnerJumpLinkWidth.setValue(cfg.getJumpLinkWidth());
      this.spinnerCollapsatorWidth.setValue(cfg.getCollapsatorBorderWidth());
      this.spinnerCollapsatorSize.setValue(cfg.getCollapsatorSize());
      this.spinnerElementBorderWidth.setValue(cfg.getElementBorderWidth());

      this.colorChooserCollapsatorBackground.setValue(cfg.getCollapsatorBackgroundColor());
      this.colorChooserCollapsatorBorder.setValue(cfg.getCollapsatorBorderColor());

      this.spinnerSelectLineWidth.setValue(cfg.getSelectLineWidth());

      this.slider1stLevelHorzGap.setValue(cfg.getFirstLevelHorizontalInset());
      this.slider1stLevelVertGap.setValue(cfg.getFirstLevelVerticalInset());

      this.slider2ndLevelHorzGap.setValue(cfg.getOtherLevelHorizontalInset());
      this.slider2ndLevelVertGap.setValue(cfg.getOtherLevelVerticalInset());

      this.comboBoxRenderQuality.setSelectedItem(cfg.getRenderQuality());
      this.checkBoxSmartTextPaste.setSelected(cfg.isSmartTextPaste());
      
      this.mapKeyShortCuts.clear();
      this.mapKeyShortCuts.putAll(cfg.getKeyShortcutMap());

      setScalingModifiers(cfg.getScaleModifiers());

      // Common behaviour options
      this.checkboxUseInsideBrowser.setSelected(preferences.getBoolean("useInsideBrowser", false));
      this.checkboxTrimTopicText.setSelected(preferences.getBoolean("trimTopicText", false));
      this.checkboxRelativePathsForFilesInTheProject.setSelected(preferences.getBoolean("makeRelativePathToProject", true));
      this.checkBoxUnfoldCollapsedTarget.setSelected(preferences.getBoolean("unfoldCollapsedTarget", true));
      this.checkBoxCopyColorInfoToNewAllowed.setSelected(preferences.getBoolean("copyColorInfoToNewChildAllowed", true));
      this.checkBoxKnowledgeFolderAutogenerationAllowed.setSelected(preferences.getBoolean(MMKnowledgeSources.PREFERENCE_KEY_KNOWLEDGEFOLDER_ALLOWED, false));
      this.checkBoxWatchFileRefactoring.setSelected(preferences.getBoolean(MindMapRefactoringFactory.PROPERTY_WATCH_FILE_REFACTORING, false));
      this.checkBoxIgnoreWhereUsedRequests.setSelected(preferences.getBoolean(MindMapRefactoringFactory.PROPERTY_IGNORE_WHEREUSED, false));

      updateFontButton(cfg);
    } finally {
      changeNotificationAllowed = true;
    }
  }

  @Nonnull
  MindMapPanelConfig store(@Nonnull final Preferences prefs, @Nonnull final MindMapPanelConfig cfg, final boolean notifyConfigReload) {
    try {
      cfg.setShowGrid(this.checkBoxShowGrid.isSelected());
      cfg.setDropShadow(this.checkBoxDropShadow.isSelected());
      cfg.setPaperColor(this.colorChooserPaperColor.getValue());
      cfg.setGridColor(this.colorChooserGridColor.getValue());
      cfg.setConnectorColor(this.colorChooserConnectorColor.getValue());
      cfg.setJumpLinkColor(this.colorChooserJumpLink.getValue());
      cfg.setRootBackgroundColor(this.colorChooserRootBackground.getValue());
      cfg.setRootTextColor(this.colorChooserRootText.getValue());
      cfg.setFirstLevelBackgroundColor(this.colorChooser1stBackground.getValue());
      cfg.setFirstLevelTextColor(this.colorChooser1stText.getValue());
      cfg.setOtherLevelBackgroundColor(this.colorChooser2ndBackground.getValue());
      cfg.setOtherLevelTextColor(this.colorChooser2ndText.getValue());
      cfg.setSelectLineColor(this.colorChooserSelectLine.getValue());
      cfg.setCollapsatorBackgroundColor(this.colorChooserCollapsatorBackground.getValue());
      cfg.setCollapsatorBorderColor(this.colorChooserCollapsatorBorder.getValue());
      cfg.setGridStep((Integer) this.spinnerGridStep.getValue());
      cfg.setSelectLineGap((Integer) this.spinnerSelectLineGap.getValue());
      cfg.setCollapsatorSize((Integer) this.spinnerCollapsatorSize.getValue());
      cfg.setConnectorWidth((Float) this.spinnerConnectorWidth.getValue());
      cfg.setJumpLinkWidth((Float) this.spinnerJumpLinkWidth.getValue());
      cfg.setSelectLineWidth((Float) this.spinnerSelectLineWidth.getValue());
      cfg.setCollapsatorBorderWidth((Float) this.spinnerCollapsatorWidth.getValue());
      cfg.setElementBorderWidth((Float) this.spinnerElementBorderWidth.getValue());

      cfg.setFirstLevelHorizontalInset(this.slider1stLevelHorzGap.getValue());
      cfg.setFirstLevelVerticalInset(this.slider1stLevelVertGap.getValue());
      cfg.setOtherLevelHorizontalInset(this.slider2ndLevelHorzGap.getValue());
      cfg.setOtherLevelVerticalInset(this.slider2ndLevelVertGap.getValue());
      cfg.setSmartTextPaste(this.checkBoxSmartTextPaste.isSelected());
      
      cfg.setRenderQuality((RenderQuality) this.comboBoxRenderQuality.getSelectedItem());

      for (final Map.Entry<String, KeyShortcut> e : this.mapKeyShortCuts.entrySet()) {
        cfg.setKeyShortCut(e.getValue());
      }

      cfg.setScaleModifiers(getScalingModifiers());

      cfg.saveTo(prefs);

      // Common behaviour options
      prefs.putBoolean("useInsideBrowser", this.checkboxUseInsideBrowser.isSelected());
      prefs.putBoolean("trimTopicText", this.checkboxTrimTopicText.isSelected());
      prefs.putBoolean("makeRelativePathToProject", this.checkboxRelativePathsForFilesInTheProject.isSelected());
      prefs.putBoolean("unfoldCollapsedTarget", this.checkBoxUnfoldCollapsedTarget.isSelected());
      prefs.putBoolean("copyColorInfoToNewChildAllowed", this.checkBoxCopyColorInfoToNewAllowed.isSelected());
      prefs.putBoolean(MMKnowledgeSources.PREFERENCE_KEY_KNOWLEDGEFOLDER_ALLOWED, this.checkBoxKnowledgeFolderAutogenerationAllowed.isSelected());
      prefs.putBoolean(MindMapRefactoringFactory.PROPERTY_WATCH_FILE_REFACTORING, this.checkBoxWatchFileRefactoring.isSelected());
      prefs.putBoolean(MindMapRefactoringFactory.PROPERTY_IGNORE_WHEREUSED, this.checkBoxIgnoreWhereUsedRequests.isSelected());
    } finally {
      if (notifyConfigReload) {
        MMDGraphEditor.notifyReloadConfig();
      }
    }
    return cfg;
  }

  private void setScalingModifiers(final int value) {
    this.checkBoxScalingALT.setSelected((value & KeyEvent.ALT_MASK) != 0);
    this.checkBoxScalingCTRL.setSelected((value & KeyEvent.CTRL_MASK) != 0);
    this.checkBoxScalingMETA.setSelected((value & KeyEvent.META_MASK) != 0);
    this.checkBoxScalingSHIFT.setSelected((value & KeyEvent.SHIFT_MASK) != 0);
  }

  private int getScalingModifiers() {
    return (this.checkBoxScalingALT.isSelected() ? KeyEvent.ALT_MASK : 0)
        | (this.checkBoxScalingCTRL.isSelected() ? KeyEvent.CTRL_MASK : 0)
        | (this.checkBoxScalingMETA.isSelected() ? KeyEvent.ALT_MASK : 0)
        | (this.checkBoxScalingSHIFT.isSelected() ? KeyEvent.SHIFT_MASK : 0);
  }

  boolean valid() {
    return true;
  }

  @Nonnull
  public MindMapPanelConfig getConfig() {
    return this.config;
  }

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton buttonAbout;
  private javax.swing.JButton buttonExportSettings;
  private javax.swing.JButton buttonFont;
  private javax.swing.JButton buttonImportSettings;
  private javax.swing.JButton buttonOpenShortcutEditor;
  private javax.swing.JButton buttonResetSettings;
  private javax.swing.JCheckBox checkBoxCopyColorInfoToNewAllowed;
  private javax.swing.JCheckBox checkBoxDropShadow;
  private javax.swing.JCheckBox checkBoxIgnoreWhereUsedRequests;
  private javax.swing.JCheckBox checkBoxKnowledgeFolderAutogenerationAllowed;
  private javax.swing.JCheckBox checkBoxScalingALT;
  private javax.swing.JCheckBox checkBoxScalingCTRL;
  private javax.swing.JCheckBox checkBoxScalingMETA;
  private javax.swing.JCheckBox checkBoxScalingSHIFT;
  private javax.swing.JCheckBox checkBoxShowGrid;
  private javax.swing.JCheckBox checkBoxSmartTextPaste;
  private javax.swing.JCheckBox checkBoxUnfoldCollapsedTarget;
  private javax.swing.JCheckBox checkBoxWatchFileRefactoring;
  private javax.swing.JCheckBox checkboxRelativePathsForFilesInTheProject;
  private javax.swing.JCheckBox checkboxTrimTopicText;
  private javax.swing.JCheckBox checkboxUseInsideBrowser;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooser1stBackground;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooser1stText;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooser2ndBackground;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooser2ndText;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserCollapsatorBackground;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserCollapsatorBorder;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserConnectorColor;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserGridColor;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserJumpLink;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserPaperColor;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserRootBackground;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserRootText;
  private com.igormaznitsa.nbmindmap.nb.swing.ColorChooserButton colorChooserSelectLine;
  private javax.swing.JComboBox<RenderQuality> comboBoxRenderQuality;
  private com.igormaznitsa.nbmindmap.nb.swing.DonateButton donateButton1;
  private javax.swing.Box.Filler filler1;
  private javax.swing.Box.Filler filler2;
  private javax.swing.Box.Filler filler3;
  private javax.swing.Box.Filler filler4;
  private javax.swing.Box.Filler filler5;
  private javax.swing.Box.Filler filler6;
  private javax.swing.Box.Filler filler7;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabel2;
  private javax.swing.JLabel jLabel3;
  private javax.swing.JLabel jLabel4;
  private javax.swing.JLabel jLabel5;
  private javax.swing.JLabel jLabel6;
  private javax.swing.JLabel jLabel7;
  private javax.swing.JPanel jPanel1;
  private javax.swing.JPanel jPanel10;
  private javax.swing.JPanel jPanel11;
  private javax.swing.JPanel jPanel12;
  private javax.swing.JPanel jPanel13;
  private javax.swing.JPanel jPanel14;
  private javax.swing.JPanel jPanel15;
  private javax.swing.JPanel jPanel16;
  private javax.swing.JPanel jPanel17;
  private javax.swing.JPanel jPanel2;
  private javax.swing.JPanel jPanel3;
  private javax.swing.JPanel jPanel4;
  private javax.swing.JPanel jPanel5;
  private javax.swing.JPanel jPanel6;
  private javax.swing.JPanel jPanel7;
  private javax.swing.JPanel jPanel8;
  private javax.swing.JPanel jPanel9;
  private javax.swing.JScrollPane jScrollPane1;
  private javax.swing.JLabel labelBorderWidth;
  private javax.swing.JLabel labelMiscNeedsReloading;
  private javax.swing.JPanel panelScalingModifiers;
  private javax.swing.JSlider slider1stLevelHorzGap;
  private javax.swing.JSlider slider1stLevelVertGap;
  private javax.swing.JSlider slider2ndLevelHorzGap;
  private javax.swing.JSlider slider2ndLevelVertGap;
  private javax.swing.JSpinner spinnerCollapsatorSize;
  private javax.swing.JSpinner spinnerCollapsatorWidth;
  private javax.swing.JSpinner spinnerConnectorWidth;
  private javax.swing.JSpinner spinnerElementBorderWidth;
  private javax.swing.JSpinner spinnerGridStep;
  private javax.swing.JSpinner spinnerJumpLinkWidth;
  private javax.swing.JSpinner spinnerSelectLineGap;
  private javax.swing.JSpinner spinnerSelectLineWidth;
  // End of variables declaration//GEN-END:variables
}
